$(function(){
	
	
	var userInfo = window.localStorage.getItem("userInfo");
	var userID = (JSON.parse(userInfo)).name_id;
	
	var vm = new Vue({
		el:"#app",
		data:{
			listData:[]
		},
		methods:{
			del:del
		},
		created:function(){
			var _this = this;
			ajax("shopSc.php","get",{
				act:"select",
				userID:userID
			},"json",function(data){
				if(data.code==200){
					console.log(data.data)
					_this.listData = data.data;
				}else{
					layer(data.msg)
				}
			},function(err){
				layer(err)
			})
		}
	})
	
	
	function del(index,item){
		var goodID = item.goodInfo.id;
		ajax("shopSc.php","post",{
			act:"del",
			goodID:goodID,
			userID:userID
		},"json",function(data){
			if(data.code==200){
				layer("取消收藏成功");
				vm.listData.splice(index,1)
			}else{
				layer(data.msg);
			}
		},function(err){
			console.log(err)
		});
	}
	
	
	
	
	
	
	
	
	
	
	
	
})
